<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改公司')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-company-edit" th:object="${company}">
		<input id="companyId" name="companyId" th:field="*{companyId}"  type="hidden">
		<div class="form-group">
			<label class="col-sm-3 control-label">公司名：</label>
			<div class="col-sm-8">
				<input id="orgName" name="orgName" th:field="*{orgName}" class="form-control" type="text" placeholder="请输入公司名称" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">公司登录码：</label>
			<div class="col-sm-8">
				<input id="companyAccount" name="companyAccount" th:field="*{companyAccount}" class="form-control" type="text" placeholder="请输入机构登录码" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">公司标识：</label>
			<div class="col-sm-8">
				<input id="compId" name="compId" th:field="*{compId}" class="form-control" type="text" placeholder="请输入机构标识码" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">过期时间：</label>
			<div class="col-sm-8">
				<input type="text" class="time-input" id="estateData" name="estateData" th:value="*{#dates.format(estateData,'yyyy-MM-dd')}" placeholder="请选择过期时间" required/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">系统IP：</label>
			<div class="col-sm-8">
				<input id="estateIp" name="estateIp" th:field="*{estateIp}" class="form-control" type="text" placeholder="请输入系统IP" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">小程序IP：</label>
			<div class="col-sm-8">
				<input id="estateAppletUrl" name="estateAppletUrl" th:field="*{estateAppletUrl}" class="form-control" type="text" placeholder="请输入小程序IP" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">资产上限：</label>
			<div class="col-sm-8">
				<input id="estateMoney" name="estateMoney" th:field="*{estateMoney}" class="form-control" type="text" placeholder="请输入大于0的整数" required>
			</div>
		</div>
	</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "estate/company";
    $("#form-company-edit").validate({
        rules: {
            onkeyup: false,
            orgName: {
                remote: {
                    url: ctx + "estate/company/checkNameUnique",
                    type: "get",
                    dataType: "json",
                    data: {
                        "companyId": function () {
                            return $("#companyId").val();
                        },
                        "orgName": function () {
                            return $.common.trim($("#orgName").val());
                        }
                    },
                    dataFilter: function (data) {
                        return $.validate.unique(data);
                    }
                }
            },
            companyAccount: {
                remote: {
                    url: ctx + "estate/company/checkAccountUnique",
                    type: "get",
                    dataType: "json",
                    data: {
                        "companyId": function () {
                            return $("#companyId").val();
                        },
                        "companyAccount": function () {
                            return $.common.trim($("#companyAccount").val());
                        }
                    },
                    dataFilter: function (data) {
                        return $.validate.unique(data);
                    }
                }
            },
            compId: {
                remote: {
                    url: ctx + "estate/company/checkCompIdUnique",
                    type: "get",
                    dataType: "json",
                    data: {
                        "companyId": function () {
                            return $("#companyId").val();
                        },
                        "compId": function () {
                            return $.common.trim($("#compId").val());
                        }
                    },
                    dataFilter: function (data) {
                        return $.validate.unique(data);
                    }
                }
            }
        },
        messages: {
            "orgName": {
                remote: "公司名称已经存在"
            },
            "companyAccount": {
                remote: "公司登录码已经存在"
            },
            "compId": {
                remote: "公司标识码已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-company-edit').serialize());
        }
    }
</script>
</body>
</html>
